package com.hp.tiger.chapter8;

import java.util.concurrent.TimeUnit;

/**
 * future -> 代表的是未来的凭据
 * futureTask -> 将你的调用逻辑进行了隔离
 * futureService -> 桥接future 和 futureTask
 *
 * @author XavierDong
 **/
public class SyncInvoker {

    public static void main(String[] args) throws InterruptedException {
      /*  String result = get();
        System.out.println(result);*/

        FutureService futureService = new FutureService();
        futureService.submit(() -> {
            try {
                TimeUnit.SECONDS.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
                Thread.currentThread().interrupt();
            }
            return "FINISH";
        }, System.out::println);

        System.out.println("========================");
        System.out.println("do other thing.");
        TimeUnit.SECONDS.sleep(1);
        System.out.println("========================");
//        System.out.println(submit.get());

    }

    private static String get() throws InterruptedException {
        TimeUnit.SECONDS.sleep(10);
        return "FINISH";
    }
}
